package com.lhj.jpa.future;

import java.util.concurrent.CompletableFuture;

/**
 * @author linghaijin781
 * @date 2021/9/229:48 下午
 */
public class _01_supplyAsync {
	public static void main(String[] args) {
		SmallTool.printTimeAndThread("小白进入餐厅");
		SmallTool.printTimeAndThread("小白点了 番茄炒蛋 + 一碗米饭");

		CompletableFuture<String> cf1 = CompletableFuture.supplyAsync(() -> {
			SmallTool.printTimeAndThread("厨师炒菜");
			SmallTool.sleepMills(200);
			SmallTool.printTimeAndThread("厨师打饭");
			SmallTool.sleepMills(100);
			return "番茄炒蛋盖浇饭 做好了";
		});

		SmallTool.printTimeAndThread("小白在打王者荣耀");
		SmallTool.printTimeAndThread(String.format("%s, 小白开吃", cf1.join()));
	}
}
